package com.aoratec.demo.network;

import java.io.File;

import android.app.ActivityManager;
import android.content.Context;

import com.webimageloader.ext.ImageHelper;
import com.webimageloader.ImageLoader;

public class WebImageUtil {
	
	public static WebImageUtil instance = new WebImageUtil();
	private WebImageUtil(){
		
	}
	
	public static WebImageUtil shareWebImageUtil(){
		return instance;
	}
	
	ImageLoader imageLoader;
	ImageHelper imageHelper;
	public void init(Context c){
		ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
        int memClass = am.getMemoryClass();
        final int memoryCacheSize = 1024 * 1024 * memClass / 8;
        
		File cacheDir = new File(c.getCacheDir(), "images");
        imageLoader = new ImageLoader.Builder(c.getApplicationContext())
               .enableDiskCache(cacheDir, 10 * 1024 * 1024)
               .enableMemoryCache(memoryCacheSize).build();
		imageHelper = new ImageHelper(c, imageLoader);
	}

	public ImageHelper getImageHelper() {
		return imageHelper;
	}
	
}
